<template>
  <div>
    <h3></h3>
    <div class="common-page__head">
      <!-- <comp-paths class="route" :paths="['/stats', $route.fullPath]"></comp-paths> -->
      <div class="title">
        <el-button type="plain" size="small" icon="el-icon-top" @click="setCity()" v-if="order">返回</el-button>
      </div>
    </div>

    <div class="common-page page-work-order" v-loading.fullscreen="loading" v-if="order">
      <div class="common-page__head">
        <div class="title">
          <span class="text" style="color:#fff">{{ order.title }}</span>
          <span class="flagd" v-for="tag in order.tags" :key="tag.id">{{ tag.name }}</span>
        </div>
        <!-- <div class="title" v-else></div> -->
      </div>
      <div class="common-page__body common-form" style="display: flex;z-index:999999;">
        <div class="rows" style="flex: 3 1 0; padding-right: 0">
          <div class="row row--head">
            <div class="named">基本信息</div>
          </div>
          <div class="row row--3x">
            <div class="named">
              <span v-if="order.company.type === 'company'">企业</span>
              <span v-else-if="order.company.type === 'project'">项目</span>
              <span v-else-if="order.company.type === 'area'">园区</span>
              <span>名称</span>
            </div>
            <div class="valued">{{ order.company.name }}</div>
          </div>
          <div class="row row--3x">
            <div class="named">事项标题</div>
            <div class="valued">{{ order.title }}</div>
          </div>
          <div class="row row--3x">
            <div class="named">调研服务小组：</div>
            <div class="valued">{{ order.fwxz }}</div>
          </div>
          <div class="row row--3x">
            <div class="named">事项描述</div>
            <div class="valued" style="white-space: pre-wrap">{{ order.content }}</div>
          </div>
          <div class="row row--3x">
            <div class="named">事项附件</div>
            <div class="valued">
              <div style="padding: 1px 0">
                <comp-files-viewer :files="order.files" v-if="order.files.length > 0"></comp-files-viewer>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="named">事项分类</div>
            <div class="valued">
              <span class="text" v-for="tag in order.tags" :key="tag.id">{{ tag.name }}</span>
            </div>
          </div>
          <div class="row">
            <div class="named">事项层面</div>

            <div class="valued">
              <div v-if="order.level == 1 ">县级</div>
              <div v-else-if="order.level == 2 ">市级</div>
              <div v-else-if="order.level == 3 ">自治区级</div>
              <div v-else>
                <span v-if="order.dept.county.id">县级</span>
                <span v-else-if="order.dept.city.id">市级</span>
                <span v-else-if="order.dept.province.id">自治区级</span>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="named">事项状态</div>
            <div class="valued">
              <span class="el-status--info" v-if="order.status === 'created'"></span>
              <span class="el-status--danger"
                    v-else-if="order.status === 'published' || order.status === 'return'"></span>
              <span class="el-status--warning" v-else-if="order.status === 'handling'"></span>
              <span class="el-status--success" v-else-if="order.status === 'finished'"></span>
              <span>{{ order.statusText }}</span>
            </div>
          </div>
          <div class="row row--2x">
            <div class="named">提交人</div>
            <div class="valued">
              <span>{{ order.creator.name }}</span>
              <span style="margin-left: 0.5em; color: #aaa">{{ order.creator.number }}</span>
            </div>
          </div>
          <div class="row">
            <div class="named">提交时间</div>
            <div class="valued">{{ order.createdAt }}</div>
          </div>

          <div class="row">
            <div class="named">服务专员</div>
            <div class="valued">
              <span>{{ order.handler.name }}</span>
              <span style="margin-left: 0.5em; color: #aaa">{{ order.handler.number }}</span>
            </div>
          </div>
          <div class="row">
            <div class="named">办结时间</div>
            <div class="valued">
              <span>{{ order.finishedAt }}</span>
            </div>
          </div>
          <div class="row">
            <div class="named">评价人</div>
            <div class="valued">
              <span>{{ order.evaluatedCreator.name }}</span>
              <span style="margin-left: 0.5em; color: #aaa">{{ order.evaluatedCreator.number }}</span>
            </div>
          </div>
          <div class="row">
            <div class="named">评价打分</div>
            <div class="valued">
              <span v-if="order.evaluated === 'yes'">{{ order.evaluatedStars }}星</span>
            </div>
          </div>
          <div class="row">
            <div class="named">评价内容</div>
            <div class="valued">
              <span v-if="order.evaluated === 'yes'">{{ order.evaluatedContent }}</span>
            </div>
          </div>
        </div>
        <div class="rows" style="flex: 2 1 0; flex-wrap: nowrap; flex-direction: column; padding-right: 0">
          <div class="row row--head">
            <div class="named">处理过程信息</div>
            <div class="valued"></div>
          </div>
          <div class="row row--3x" style="flex: 1 1 0; overflow-x: hidden; overflow-y: auto">
            <div class="value">
              <trackscp :order="order"></trackscp>
            </div>
          </div>
        </div>
      </div>

    </div>
    <div class="common-page__body page-stats-order-city__body" v-else>
      <div class="row">
        <div class="col col--2em" style="font-size: 20px;color: transparent;background: transparent;"><span>1</span></div>
        <div class="col" style="font-size: 26px;background: transparent">
          <span>企业名称</span>
        </div>

        <div class="col" style="font-size: 26px;background: transparent">标题</div>
        <div class="col col--4em" style="font-size: 26px;background: transparent">状态</div>
      </div>
      <div class="row fixed" v-for="(city, index) in cityList" :key="city.id">
        <div class="col col--2em" style="font-size: 20px">
          <span>{{ index + 1 }}</span>
        </div>

        <div class="col" @click="setxian(city.id)"
             style="cursor: pointer; color:#fff;font-size: 20px;text-decoration:underline;">{{ city.name }}
        </div>

        <div class="col" style="font-size: 20px">{{ city.title }}</div>
        <div class="col col--4em" style="font-size: 20px"
             :class="[city.status=='已办结'?'qq':'',city.status=='处理中'?'ww':'',city.status=='已提交'?'ww':'',city.status=='待提交'?'ww':'',city.status=='已退回'?'ww':'']">
          {{ city.status }}
        </div>

      </div>
    </div>


  </div>
</template>
<script>
import user from "../../plugins/user"
import trackscp from "../../comps/order-trackscp.vue";

import {string, int} from "../../util";

export default {
  name: "timeRangOrder",
  props: {
    startTime: {
      type: Date,
      default: () => null,
    },
    endTime: {
      type: Date,
      default: () => null,
    },
  },
  data: () => ({
    loading: false,
    cityId: "",
    cityList: [],
    xiangqingList: [],
    open: false,
    countryList: [],
    areaId: null,
    status: null,
    oopenfa: true,
    order: null,
  }),
  components: {
    trackscp
  },
  methods: {
    getsetxian(params) {
      // user.getparticularsevent(params).then((res) => {
      user.getOrder(params).then((res) => {
        this.loading = false;
        if (res.code === 0) {
          this.order = res.data
        } else {

        }
      });
    },
    setban(params, b) {
      this.status = b
      this.areaId = params

      this.open = true;
      this.getsetxian(a)
    },
    setxian(params) {
      this.areaId = params;
      this.cityId = '999999'
      this.open = true;
      this.getsetxian(params)
    },
    setCity(city) {
      this.oopenfa = true;
      this.order = null;

      this.cityId = '';
      this.countryList = [];
      if (this.loading) return;
      this.cityId = city ? city.id : "";
      this.search(true);
    },
    search(clean) {
      if(this.startTime == null || this.endTime == null){
        return;
      }

      if (this.loading) return;
      if (clean) this.cityList = [];
      this.loading = true;
      user.getTimeRangOrderData({
        startTime:this.startTime.getTime(),
        endTime:this.endTime.getTime()
      }).then((res) => {
        this.loading = false;
        if (res.code === 0) {
          var sslist = []
          res.data.forEach(e => {
            var sslistobj = {}
            sslistobj.id = e.orderId;
            sslistobj.title = e.title;
            sslistobj.name = e.corpName;
            if (e.status == 1) {
              sslistobj.status = '待提交'
            } else if (e.status == 2) {
              sslistobj.status = '已提交'

            } else if (e.status == 3) {
              sslistobj.status = '已退回'

            } else if (e.status == 4) {
              sslistobj.status = '处理中'

            } else if (e.status == 5) {
              sslistobj.status = '已办结'

            }
            sslist.push(sslistobj)
          });
          this.cityList = sslist;
        } else {

        }
      });
    },
  },
  mounted() {
    this.search();
  }
}
</script>

<style lang="scss" scoped>
@import '../../common/common.css';

h3 {
  color: white;
  font-size: 48px;
  text-align: center;
  height: 60px;
  line-height: 60px;
}

.qq {
  color: rgb(86, 229, 86) !important;
}

.ww {
  color: yellow !important;
}

.ee {
  color: #f52929 !important;
}

.common-page__head {
  margin: 0;
}

.common-page__body {
  height: 73.5vh;

  .fixed {
    width: 100%;
    // overflow-y: auto;

  }

  .row {
    width: 100%;
    // background: red;
    color: white;

    .col {
      background-color: rgba(0, 24, 106, 0.5);
      color: white;
      line-height: 30px;

    }
  }

}

.pagecoun {
  height: 68vh;
  overflow-y: auto;

  .TableLis {
    .tabloading {
      position: relative;
      left: 45%;
      width: 200px;
      height: 200px;
      font-size: 20px;
      line-height: 200px;
      color: white;
      text-align: center;
    }

    .tali ::v-deep .el-table__row {
      background-color: #0C1E5E;

      color: white;
    }

    .tali ::v-deep tr:hover > td {
      background-color: #1808c3;
    }
  }
}


.page-work-order {
  overflow: hidden;
  height: 70vh;
}


</style>
